package com.jprocms.module.cms.config;

import com.jpro.framework.common.enums.WebFilterOrderEnum;
import com.jpro.framework.tenant.core.web.TenantContextWebFilter;
import com.jpro.module.bpm.api.task.BpmProcessInstanceApi;
import com.jpro.module.bpm.api.task.rpc.BpmTaskApi;
import com.jpro.module.infra.api.config.ConfigApi;
import com.jpro.module.infra.api.config.FileConfigApi;
import com.jpro.module.infra.api.file.FileApi;
import com.jpro.module.system.api.dept.DeptApi;
import com.jpro.module.system.api.dict.DictDataApi;
import com.jpro.module.system.api.notice.NoticeApi;
import com.jpro.module.system.api.sensitiveword.SensitiveWordApi;
import com.jpro.module.system.api.sms.SmsCodeApi;
import com.jpro.module.system.api.user.AdminUserApi;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {ConfigApi.class, FileConfigApi.class, SmsCodeApi.class, FileApi.class, AdminUserApi.class, DeptApi.class, DictDataApi.class, BpmProcessInstanceApi.class, BpmTaskApi.class, SensitiveWordApi.class, NoticeApi.class})
public class RpcConfiguration {
    @Bean
    public FilterRegistrationBean<TenantContextWebFilter> tenantContextWebFilter() {
        //从header解析租户信息，调用system服务需要租户信息
        FilterRegistrationBean<TenantContextWebFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new TenantContextWebFilter());
        registrationBean.setOrder(WebFilterOrderEnum.TENANT_CONTEXT_FILTER);
        return registrationBean;
    }

}
